package com.xierong.remoteplayerlauncher.recevier;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class ExternalStorageReceiverHelper extends BroadcastReceiver {
    private ExternalStorageCommand command;
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        switch(action) {
            case ExternalStorageReceiver.EXTERNAL_STORAGE_CONFIG_PATH: {
                command.processConfig(intent.getExtras().getString("path"));
            }break;
            case ExternalStorageReceiver.EXTERNAL_STORAGE_NO_CONFIG: {
                command.noConfig();
            }break;
            case ExternalStorageReceiver.EXTERNAL_STORAGE_UNMOUNTED: {
                command.externalStorageUnmounted();
            }break;
        }
    }
    public interface  ExternalStorageCommand {
        void processConfig(String path);
        void noConfig();
        void externalStorageUnmounted();
    }
    public void setCommand(ExternalStorageCommand command) {
        this.command = command;
    }
}
